home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-07-17 | 36.4 KB | 1,485 lines |
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Description:
- // Create the 'Hardware Render Buffer' window.
- //
- // Contents
- // resizeBufferRW() Resize the render buffer and widow.
- // setMenuStateRW() Enable/disable size buttons.
- // glResizePort() Resize the render buffer and widow (user access).
- // scaleBufMenuRW() Callback for the pulldown scale menu.
- // displayTimelineRW() Set the visibility of the shelf tool.
- // playbackRW() Callback for the playback buttons.
- // playbackScriptJobRW() Script job for playback buttons.
- // resChangedScriptJobRW() Script job for resolution attribute changes.
- // updateCameraMenuRW() Update the camera pulldown menu.
- //
- // flipbookRW() Callback to setup for flipbook.
- // updateFlipbookMenuRW() Update the flipbook pulldown menu.
- // clearFlipbookMenuRW() Callback for the clear flipbook menu option.
- // setFlipbookFlagsRW() Callback for the set flipbook flags option.
- // runFlipbookRW() Callback for a flipbook menu item.
- // flipbookOptionMenuRW(); Build the Flipbook option menu.
- // buildHardwareRenderBuffContextHelpItems() Creates context sensitive
- // menu items for the hardware render buffer.
- //
- // createWinRW() Create the window and all components..
- // registerRW() Register callbacks with the ui widgets.
- // updateWinRW() Update the window to match current render states.
- // glRenderWin() Main entry point.
- //
-
-
- global int $glWinCameraCount = 4;
- global int $glRenderBufferWidth = 646;
- global int $glRenderBufferHeight = 485;
- global float $glRenderBufferAspect = 1.33;
- global float $glRenderBufferScale = 1.0;
- global string $glRenderBufferWin;
- global string $glFlipbookOptions = "";
-
- // Global variables to store the menu items after the window is closed
- global string $glHWBufferItemCallbacks[];
- global string $glHWBufferItemLabels[];
-
- // Must be sorted from high to low.
- global float $glHWrenderScales[] = {1., .7, .5, .3, .1};
-
- global proc doGlRender()
- {
- int $multipass = `getAttr defaultHardwareRenderGlobals.multiPassRendering`;
- if ($multipass != 0) {
- string $sl[] = `ls -sl`;
- if (size($sl) > 0) {
- warning("If Hardware Render does not stay on screen, you may need to clear your selection.");
- }
- }
- glRender -renderFrame hardwareRenderView;
- }
-
-
- // ========== isSizeOkayRW ==========
- //
- // Description:
- // Check if the given viewport dimensions make the
- // window to big to fit on the screen.
- //
-
- proc int isSizeOkayRW( int $width, int $height, float $scale )
- {
- int $w = $scale * $width;
- int $h = $scale * $height;
-
- if (($w < 100) || ($w > 1100) || ($h < 100) || ($h > 825))
- return 0;
- return 1;
- }
-
-
-
- // ========== setMenuStateRW ==========
- //
- // Description:
- // Enable/disable the menu buttons as needed. This
- // is to prevent the user from sizing the window
- // too big or too small.
- //
-
- proc setMenuStateRW()
- {
- global int $glRenderBufferWidth;
- global int $glRenderBufferHeight;
- global float $glHWrenderScales[];
-
- int $state;
-
- setParent glRenderWindow;
-
- for ($i = 0; $i < size($glHWrenderScales) ; $i++)
- {
- $state = isSizeOkayRW($glRenderBufferWidth, $glRenderBufferHeight,
- $glHWrenderScales[$i]);
- menuItem -e -enable $state ("scaleItem"+$i);
- }
- }
-
-
-
- // ========== findGoodSizeRW ==========
- //
- // Description:
- // Find a good window size for the current buffer selection.
- // If the current scale is okay, then use it, otherwise
- // find the largest scale that is valid.
- //
-
- proc findGoodSizeRW()
- {
- global int $glRenderBufferWidth;
- global int $glRenderBufferHeight;
- global float $glRenderBufferScale;
- global float $glHWrenderScales[];
-
- setParent glRenderWindow;
-
- if (isSizeOkayRW($glRenderBufferWidth, $glRenderBufferHeight,
- $glRenderBufferScale ))
- {
- return;
- }
-
- for ($i = 0; $i < size($glHWrenderScales) ; $i++)
- {
- if (isSizeOkayRW($glRenderBufferWidth, $glRenderBufferHeight,
- $glHWrenderScales[$i]))
- {
- $glRenderBufferScale = $glHWrenderScales[$i];
- menuItem -e -rb true -enable true ("scaleItem"+$i);
- break;
- }
- }
-
- // Now enable/disable the menu buttons for the valid sizes.
- //
- setMenuStateRW();
- }
-
-
-
- // ========== resizeBufferRW ==========
- //
- // Description:
- // Resize the render buffer and window. The size is
- // read from global variables.
- //
-
- global proc resizeBufferRW( float $scale )
- {
- // Check if new scale set.
- //
- if ($scale > 0.0)
- {
- global float $glRenderBufferScale;
-
- $glRenderBufferScale = $scale;
- }
- else
- {
- // Make sure the window is a good size. If the window is
- // too big, or too small, resize it. Then dim the menu
- // items that would create bad window sizes.
- //
- findGoodSizeRW();
- }
-
-
- // Render layout minimum size.
- //
- int $minWidth = 323;
- int $minHeight = 200;
-
-
- // Set view pane to image size.
- global int $glRenderBufferWidth;
- global int $glRenderBufferHeight;
- global float $glRenderBufferAspect;
- global float $glRenderBufferScale;
-
-
- //
- // GG: need to add 4 to each side for frameLayout border.
- //
- int $margin = 4;
- int $fudgeW = $margin;
- int $fudgeH = $margin;
-
- if (!`about -nt` && !`about -mac`)
- {
- // The (Motif) ui seems to need a fudge
- // factor of 4 in order to get the correct viewport size.
- //
-
- $fudgeW = $fudgeW + 2;
- $fudgeH = $fudgeH - 4;
- } else if ( `about -mac` ) {
- // The mac ui does not need a fudge factor
- //
- $fudgeH = 0;
- }
-
-
- // Set the image output resolution in the hardware render manager.
- //
- glRender -e -imageSize $glRenderBufferWidth $glRenderBufferHeight $glRenderBufferAspect;
-
-
- // Set the viewport size for rendering.
- //
- int $imageWidth = $glRenderBufferScale * $glRenderBufferWidth + 0.5;
- int $imageHeight = $glRenderBufferScale * $glRenderBufferHeight + 0.5;
-
- glRender -e -viewport $imageWidth $imageHeight $glRenderBufferAspect;
-
-
- // Now make the window a little bigger to accomodate errors
- // in the elf widget hierarchy.
- //
- int $frameWidth = $imageWidth + $fudgeW;
- int $frameHeight = $imageHeight + $fudgeH;
-
- // Make sure window does not get too small.
- //
- int $marginWidth = 4;
- int $marginHeight = 4;
-
- if (($frameWidth + (2 * $marginWidth)) < $minWidth)
- {
- $marginWidth = (($minWidth - $frameWidth) / 2.0) + 0.5;
- }
-
- if (($frameHeight + (2 * $marginHeight)) < $minHeight)
- {
- $marginHeight = (($minHeight - $frameHeight) / 2.0) + 0.5;
- }
-
-
- // Set view panel to the new image size.
- //
- if( `about -mac`)
- {
- setParent ("glRenderWindow"+"|renderBufferForm"+"|glRenderMenLayout"+"|workLyt");
- }
- else {
- setParent glRenderWindow;
- }
-
- formLayout -e
- -af viewFrame left $marginWidth
- -af viewFrame top $marginHeight
- -af viewFrame right $marginWidth
- -af viewFrame bottom $marginHeight
- viewLyt;
-
-
- // I now need to set both the width and
- // height on the window directly. (12/17/96)
- //
- int $width = $frameWidth + (2 * $marginWidth);
- int $height = $frameHeight + 30 + (2 * $marginHeight);
-
- if (`menuItem -q -checkBox timelineItem`)
- {
- int $x = `formLayout -q -height timeLineLyt`;
-
- $height = $height + `formLayout -q -height timeLineLyt`;
- }
-
- if (`about -nt`)
- {
- //
- // GG: Irix sizes assumming a 30 pixel high
- // title bar. On NT, there is no fixed title bar height, instead
- // we can set the size of the top-level layout, but we need
- // to subtract the 30 pixels added for irix.
- // also, since a window will only "grow" in size, we first size
- // the window to its smallest size.
- //
- window -e -widthHeight 1 1 glRenderWindow;
- control -e -width $width -height ($height-30) ("glRenderWindow"+"|workLyt");
- }
- else
- {
- if (`about -mac`)
- {
- //window -e -widthHeight $width $height ("glRenderWindow");
- //control -e -width $width -height $height ("glRenderWindow"+"|renderBufferForm"+ "|glRenderMenLayout" + "|workLyt");
- //We need to add the size of the menubar
- window -e -widthHeight $width ($height+12) glRenderWindow;
- }
- else
- window -e -widthHeight $width $height glRenderWindow;
- }
-
- // Enable/disable the menu buttons for the
- // current buffer size.
- //
- setMenuStateRW();
-
-
- } // resizeBufferRW //
-
-
-
- // ========== glResizePort ==========
- //
- // Description:
- // Resize the render buffer and window. This is a hidden
- // access method to resize the render port to an arbitrary
- // size.
- //
-
- global proc glResizePort( int $width, int $height )
- {
- global int $glRenderBufferWidth;
- global int $glRenderBufferHeight;
-
- $glRenderBufferWidth = $width;
- $glRenderBufferHeight = $height;
-
- resizeBufferRW( 0.0 );
- }
-
-
- // ========== scaleBufMenuRW ==========
- //
- // Description:
- // Callback for the buffer scale pulldown menu.
- // Also sets the scale option menu.
- //
-
- global proc scaleBufMenuRW( string $win, int $scale )
- {
- global float $glHWrenderScales[];
-
- setParent $win;
- resizeBufferRW($glHWrenderScales[$scale]);
- }
-
- global proc flipbookOptionMenuRW()
- {
- global string $glRenderBufferWin;
- setParent $glRenderBufferWin;
-
- if(`about -mac`)
- {
- menuItem -p flipbookMenu
- -l "Clear Flipbook Menu"
- -c "clearFlipbookMenuRW"
- clearFlipbookItem;
- }else{
- menuItem -p flipbookMenu
- -l "Options"
- -subMenu true
- flipbookOptionsItem;
-
- menuItem -l "Clear Flipbook Menu"
- -c "clearFlipbookMenuRW"
- clearFlipbookItem;
-
- menuItem -l "Flipbook Flags..."
- -c "setFlipbookFlagsRW"
- flipbookFlagsItem;
-
- setParent -menu ..;
- }
- }
-
- global proc updateFlipbookMenuRW(string $label, string $cbArgList)
- {
- global string $glRenderBufferWin;
- global string $glHWBufferItemCallbacks[];
- global string $glHWBufferItemLabels[];
- setParent $glRenderBufferWin;
-
- int $i, $j;
- int $numCurrFlipbooks = size($glHWBufferItemLabels);
- for ($i = 0 ; $i<$numCurrFlipbooks ; $i++ )
- {
- // If the item is already there, just move it up
- if ($label == $glHWBufferItemLabels[$i])
- break;
- }
-
- // Item was not found, make some room
- if ($i >= $numCurrFlipbooks)
- {
- $numCurrFlipbooks++;
- if ($numCurrFlipbooks > 10) $numCurrFlipbooks = 10;
- print ("FlipBooks: "+$numCurrFlipbooks+"\n");
- }
- else
- $numCurrFlipbooks = $i+1;
-
- // Move all the items by one slot, to free up one space
- for ($i = $numCurrFlipbooks-1 ; $i > 0 ; $i-- )
- {
- $glHWBufferItemCallbacks[$i] = $glHWBufferItemCallbacks[$i-1];
- $glHWBufferItemLabels[$i] = $glHWBufferItemLabels[$i-1];
- }
-
- // Add the new item
- $glHWBufferItemLabels[0] = $label;
- $glHWBufferItemCallbacks[0] = ("runFlipbookRW " + $cbArgList);
-
- // Delete the old menu and rebuild, with the new item on top.
- menu -e -dai flipbookMenu;
-
- for ($i = 0 ; $i < $numCurrFlipbooks ; $i++)
- menuItem -p flipbookMenu
- -l $glHWBufferItemLabels[$i] -c $glHWBufferItemCallbacks[$i];
-
- flipbookOptionMenuRW();
- }
-
- // ========== flipbookRW ==========
- //
- // Description:
- // Called when the user has competed a render sequence. Set up
- // to allow the user to run fcheck to see the sequence.
- //
-
- global proc flipbookRW( string $image,
- int $fs, int $fe, int $fi, int $rate,
- string $path, string $filename )
- {
- // Build a label for the pulldown menu item. It will be the
- // <imageName>.<startFrame>-<endFrame>
- //
- string $label = $image + "." + $fs + "-" + $fe;
- string $fullName = $path;
- if (substring($path, size($path), size($path)) != "/")
- $fullName = $fullName + "/";
-
- $fullName = "\"" + $fullName + $filename + "\"";
- string $rateString;
- switch ($rate)
- {
- case 24: $rateString = "film ";
- break;
- case 30: $rateString = "ntsc ";
- break;
- case 25: $rateString = "pal";
- break;
- default:
- $rateString = "none";
- break;
- }
-
- string $argList = $fs + " " + $fe + " " + $fi + " " + $rateString + " ";
- $argList = $argList + $fullName;
-
- updateFlipbookMenuRW($label, $argList);
- }
-
-
- // ========== clearFlipbookMenuRW ==========
- //
- // Description:
- // Callback for Flipbook->Options->Clear Flipbook Menu.
- // Clear the menu, then remake the options menu items.
- //
-
- global proc clearFlipbookMenuRW()
- {
- global string $glHWBufferItemCallbacks[];
- global string $glHWBufferItemLabels[];
-
- menu -e -dai flipbookMenu;
- clear $glHWBufferItemCallbacks;
- clear $glHWBufferItemLabels;
-
- flipbookOptionMenuRW();
- }
-
-
-
- // ========== FFokBtnRW ==========
- //
- // Description:
- // This is the callback for the OK button in the
- // flipbook options dialog. It saves the new flags
- // in the global flags variable.
- //
-
- global proc FFokBtnRW( string $win )
- {
- global string $glFlipbookOptions;
-
- setParent $win;
- $glFlipbookOptions = `textField -q -text flipbookFlagsTF`;
- window -e -vis 0 $win;
- }
-
-
-
- // ========== FFcancelBtnRW ==========
- //
- // Description:
- // This is the callback for the Cancel button in the
- // flipbook options dialog. It restores the fcheck flags
- // into the textfield.
- //
-
- global proc FFcancelBtnRW( string $win )
- {
- global string $glFlipbookOptions;
-
- setParent $win;
- textField -e -text $glFlipbookOptions flipbookFlagsTF;
- window -e -vis 0 $win;
- }
-
-
-
- // ========== setFlipbookFlagsRW ==========
- //
- // Description:
- // This is the callback for Flipbook->Options->Flipbook Flags .
- // It brings up a dialog for the user to set additional flags.
- //
-
- global proc setFlipbookFlagsRW()
- {
- if (!`window -exists flipbookFlagsWin`)
- {
- window
- -title "Flipbook Options"
- -retain
- -widthHeight 420 130
- -interactivePlacement
- flipbookFlagsWin;
-
- frameLayout
- -borderVisible false
- -collapsable false
- -labelVisible false
- -marginHeight 2
- flipbookFlagsFL;
-
- formLayout
- -numberOfDivisions 100
- flipBookFlagsF;
-
- text
- -label "Set any options for fcheck except \"-n\" and \"-r\", which are"
- -align "left"
- text1RW;
-
- text
- -label "set to the frame range, increment and rate you rendered with."
- -align "left"
- text2RW;
-
- text
- -label "Options:"
- -align "left"
- optionsTextRW;
-
- textField
- -width 280
- -text ""
- flipbookFlagsTF;
-
- button
- -label "OK"
- -height 26
- -command "FFokBtnRW flipbookFlagsWin"
- flipbookFlagsOKBtn;
-
- button
- -label "Cancel"
- -height 26
- -command "FFcancelBtnRW flipbookFlagsWin"
- flipbookFlagsCancelBtn;
-
- formLayout -e
- -af text1RW top 0
- -af text1RW left 20
- -ac text2RW top 0 text1RW
- -af text2RW left 20
- -ac optionsTextRW top 10 text2RW
- -af optionsTextRW left 20
- -ac flipbookFlagsTF top 8 text2RW
- -ac flipbookFlagsTF left 4 optionsTextRW
- -af flipbookFlagsTF right 20
- -af flipbookFlagsOKBtn left 10
- -ap flipbookFlagsOKBtn right 5 50
- -af flipbookFlagsOKBtn bottom 10
- -af flipbookFlagsCancelBtn right 10
- -ap flipbookFlagsCancelBtn left 5 50
- -af flipbookFlagsCancelBtn bottom 10
- flipBookFlagsF;
- }
-
- showWindow flipbookFlagsWin;
- }
-
-
- // ========== runFlipbookRW ==========
- //
- // Description:
- // This is the callback for the Flipbook menu items.
- // It will execute fcheck with the arguments supplied.
- //
-
- global proc runFlipbookRW( int $fs, int $fe, int $fi,
- string $rate,
- string $filename)
- {
- global string $glFlipbookOptions = "";
-
- string $cmd;
- $cmd = "fcheck ";
- if(`about -mac`) {
- $cmd = $cmd + "-r " + $rate;
- $cmd = $cmd + " -n " + $fs + " " + $fe + " " + $fi;
- }
- else {
- $cmd = $cmd + "-n " + $fs + " " + $fe + " " + $fi;
- $cmd = $cmd + " -r " + $rate;
- }
-
- if (size($glFlipbookOptions) > 0)
- $cmd = $cmd + " " + $glFlipbookOptions + " ";
- $cmd = $cmd + " \"" + $filename + "\"";
-
- print( "// Result: "+$cmd+"\n" );
-
- if (`about -nt` || `about -mac`)
- {
- eval ($cmd);
- } else {
- system($cmd+">/dev/null 2>&1"); // GG: Irix Only
- }
- }
-
-
- // ========== displayTimelineRW ==========
- //
- // SYNOPSIS
- // Toggle the display of the timeline tool.
- //
-
- global proc displayTimelineRW( string $win, int $visible )
- {
-
- if ($visible)
- {
- formLayout -e -vis true ($win+"|workLyt|timeLineLyt");
- setParent ($win+"|workLyt");
- formLayout -e -ac viewLyt bottom 0 timeLineLyt ($win+"|workLyt");
- }
- else
- {
- formLayout -e -vis false ($win+"|workLyt|timeLineLyt");
- setParent ($win+"|workLyt");
- formLayout -e -af viewLyt bottom 0 ($win+"|workLyt");
- }
-
-
- // Force the window to resize correctly.
- //
- resizeBufferRW( 0.0 );
- }
-
- // ========== playbackRW ==========
- //
- // Description:
- // Callback for the playback buttons. Controls playing forward,
- // backward, etc. Mimic the same behavior as the timeSlider
- // buttons in the main window.
- //
-
- global proc playbackRW( string $win, int $mode )
- {
- setParent $win;
-
- switch ($mode)
- {
- case 1 : // Rewind
- {
- currentTime -edit `playbackOptions -query -min`;
- } break;
-
-
- case 2 : // Step backward
- {
- float $by = `playbackOptions -query -by`;
- float $curr = `currentTime -query`;
- float $min = `playbackOptions -query -min`;
-
- if (($curr - $by) >= $min)
- {
- currentTime -edit ($curr - $by);
- }
- } break;
-
-
- case 3 : // Play backward
- {
- if ((`play -query -state` == 1) && (`play -query -forward` == 0))
- {
- // Stop playback. Let the script job reset the button images.
- //
- play -state off;
- }
- else
- {
- if (`currentTime -q` <= `playbackOptions -q -min`)
- {
- currentTime -e `playbackOptions -q -max`;
- }
-
- symbolButton -edit -image "timestop.xpm"
- -ann "Stop playback" playBwdBtn;
-
- if (`symbolButton -q -i playFwdBtn` != "timeplay.xpm")
- {
- symbolButton -edit -image "timeplay.xpm"
- -ann "Play forward" playFwdBtn;
- }
-
- play -forward off;
- }
- } break;
-
-
- case 4 : // Play forward
- {
- if ((`play -query -state` == 1) && (`play -query -forward` == 1))
- {
- // Stop playback. Let the script job reset the button images.
- //
- play -state off;
- }
- else
- {
- if (`currentTime -q` >= `playbackOptions -q -max`)
- {
- currentTime -e `playbackOptions -q -min`;
- }
-
- symbolButton -edit -image "timestop.xpm"
- -ann "Stop playback" playFwdBtn;
-
- if (`symbolButton -q -i playBwdBtn` != "timerev.xpm")
- {
- symbolButton -edit -image "timerev.xpm"
- -ann "Play backwards" playBwdBtn;
- }
-
- play -forward on;
- }
- } break;
-
-
- case 5 :
- {
- float $by = `playbackOptions -query -by`;
- float $curr = `currentTime -query`;
- float $max = `playbackOptions -query -max`;
-
- if (($curr + $by) <= $max)
- {
- currentTime -edit ($curr + $by);
- }
- } break;
-
-
- case 6 :
- {
- currentTime -edit `playbackOptions -query -max`;
- } break;
- }
- } // playbackRW //
-
-
-
- // ========== playbackScriptJobRW ==========
- //
- // Description:
- // Make sure that the buttons are in sync with the current
- // playback mode. This script job gets called whenever the
- // playback state changes. BUG: this script actually only
- // gets called when playback stops.
- //
-
- global proc playbackScriptJobRW( string $win )
- {
- if (!`window -q -visible $win`) return;
-
- if (`play -query -state` == 0)
- {
- setParent $win;
-
- if (`symbolButton -q -i playBwdBtn` != "timerev.xpm")
- {
- symbolButton -edit -image "timerev.xpm"
- -ann "Play backwards" playBwdBtn;
- }
-
- if (`symbolButton -q -i playFwdBtn` != "timeplay.xpm")
- {
- symbolButton -edit -image "timeplay.xpm"
- -ann "Play forward" playFwdBtn;
- }
- }
- } // playbackScriptJobRW //
-
-
-
- // ========== resChangedScriptJobRW ==========
- //
- // Description
- // This proc gets called whenever the resolution attribute
- // on the hwRenderGlobals node changes. This proc is
- // used to resize the hardware render window to make sure
- // its in sync with the attribute value.
- //
-
- global proc resChangedScriptJobRW( string $win )
- {
- // Get the name of the hardware render globals node.
- //
- string $hwNodes[] = `ls -type hwRenderGlobals`;
- if (size( $hwNodes ) == 0) return;
-
-
- // Get the new resolution values.
- //
- string $hwRes = `getAttr ($hwNodes[0]+".resolution")`;
- string $tokenAry[];
- int $width, $height;
- float $aspect;
-
- tokenize( $hwRes, " ", $tokenAry );
- $width = $tokenAry[1];
- $height = $tokenAry[2];
- $aspect = $tokenAry[3];
-
-
- // Store the new values in the global variables for the
- // scripts to use. Then call the resize proc.
- //
- global int $glRenderBufferWidth;
- global int $glRenderBufferHeight;
- global float $glRenderBufferAspect;
-
- $glRenderBufferWidth = $width;
- $glRenderBufferHeight = $height;
- $glRenderBufferAspect = $aspect;
-
- resizeBufferRW( 0.0 );
- } // resChangedScriptJobRW //
-
-
-
- // ========== updateCameraMenuRW ==========
- //
- // Description:
- // Update the camera pulldown menu. Use the camera shape
- // name as the label.
- //
-
- global proc updateCameraMenuRW( string $win )
- {
- setParent $win;
-
- // Get the current list of cameras in the scene. The ls command
- // returns shape names. Prune this list to return the parent
- // transform name.
- //
- string $cameraShapeAry[] = `ls -cameras`;
- int $cameraShapeCnt = size( $cameraShapeAry );
- string $cameraNameAry[] = `ls -long -cameras`;
- int $cameraNameCnt = $cameraShapeCnt;
-
- for ($i = 0; $i < $cameraNameCnt; $i++)
- {
- string $words[];
-
- tokenize( $cameraNameAry[$i], "|", $words );
- $cameraNameAry[$i] = $words[size( $words ) - 2];
- }
-
-
- // Rebuild the camera pulldown menu as needed to match
- // the current list of available cameras.
- //
- global int $glWinCameraCount;
- $glWinCameraCount = `menu -q -ni cameraMenu`;
- int $i, $loopCnt, $doCase;
- int $camCnt = $cameraNameCnt;
- string $activeCamera = `glRenderEditor -q -vcn hardwareRenderView`;
-
-
- if ($glWinCameraCount == $camCnt)
- {
- $loopCnt = $glWinCameraCount;
- $doCase = 0;
- }
- else if ($glWinCameraCount < $camCnt)
- {
- $loopCnt = $glWinCameraCount;
- $doCase = 1;
- }
- else
- {
- $loopCnt = $camCnt;
- $doCase = 2;
- }
-
- // Update existing button labels and callback actions.
- //
- for ($i = 0; $i < $loopCnt; $i++)
- {
- string $btnName = "glCameraItem"+$i;
- string $btnLbl = `menuItem -q -l $btnName`;
-
- if ($btnLbl != $cameraNameAry[$i])
- {
- menuItem -e
- -l $cameraNameAry[$i]
- -cl glCameraCluster
- -c ("glRenderEditor -e -lookThru "+$cameraShapeAry[$i]+" hardwareRenderView")
- $btnName;
- }
-
- menuItem -e -rb ($activeCamera == $cameraShapeAry[$i] ? true : false) $btnName;
- }
-
-
- // Add buttons to camera menu for new cameras.
- //
- if ($doCase == 1)
- {
- for ($i = $loopCnt; $i < $camCnt; $i++)
- {
- global int $glWinCameraCount;
- string $btnName = "glCameraItem"+$glWinCameraCount;
-
- $glWinCameraCount++;
-
- menuItem
- -p cameraMenu
- -l $cameraNameAry[$i]
- -rb ($activeCamera == $cameraShapeAry[$i] ? true : false)
- -cl glCameraCluster
- -c ("glRenderEditor -e -lookThru "+$cameraShapeAry[$i]+" hardwareRenderView")
- $btnName;
- }
- }
-
-
- // Delete extra buttons from camera menu.
- //
- if ($doCase == 2)
- {
- setParent -menu cameraMenu;
-
- for ($i = $glWinCameraCount; $i > $loopCnt; $i--)
- {
- global int $glWinCameraCount;
- $glWinCameraCount--;
- string $btnName = "glCameraItem"+$glWinCameraCount;
- deleteUI -menuItem $btnName;
- }
- }
- } // updateCameraMenuRW //
-
- // ========== buildHardfwareRenderBuffContextHelpItems ===========
- //
- // SYNOPSIS
- // Build context sensitive menu items for the
- // hardware render buffer window.
- //
- // Input Arguments:
- // $nameRoot - name to use as the root of all item names
- // $menuParent - the name of the parent of this menu
- //
- global proc buildHardwareRenderBuffContextHelpItems(string $nameRoot, string $menuParent)
- {
- menuItem -label "Help on Hardware Render Buffer..."
- -enableCommandRepeat false
- -command "showHelp HardwareRenderBuffer";
- }
-
- // ========== createMenuRW ==========
- //
- // SYNOPSIS
- // Create the menu and all the menu items.
- //
-
- proc createMenuRW( string $parent )
- {
- global string $glHWBufferItemCallbacks[];
- global string $glHWBufferItemLabels[];
- global float $glHWrenderScales[];
- // Create the menubar.
- //
- menu -p $parent
- -label "File"
- -familyImage "menuIconFile.xpm"
- glFileMenu;
- // menuItem -l "Save As..." saveAsFileItem;
- menuItem -l "Close" -c ("window -e -vis 0 glRenderWindow") closeWinItem;
- setParent -menu ..;
-
- menu -p $parent
- -label "Render"
- -familyImage "menuIconRender.xpm"
- renderMenu;
- menuItem -l "Attributes..." -c "editRenderGlobalsRW";
- menuItem -l "Test Render" -c "glRender -renderFrame hardwareRenderView" renderFrameItem;
- // menuItem -l "Post Current Image" -c "print \"Post Current Image\\n\"" postImageItem;
- menuItem -l "Render Sequence" -c "glRender -renderSequence hardwareRenderView" renderSeqItem;
- menuItem -l "Scale Buffer" -sm true bufferScaleItem;
- radioMenuItemCollection hwBufferScaleCluster;
- for ($i = 0; $i < size($glHWrenderScales) ; $i++)
- {
- string $label = (($glHWrenderScales[$i]*100)+" %");
- menuItem -l $label -rb false
- -c ("scaleBufMenuRW "+$parent+" "+$i) ("scaleItem"+$i);
- }
- menuItem -e -rb true scaleItem0;
- setParent -menu ..;
- menuItem -l "Time Slider" -checkBox on -c ("displayTimelineRW " +$parent+ " #1") timelineItem;
- setParent -menu ..;
-
- menu -p $parent
- -label "Cameras"
- -pmc ("updateCameraMenuRW "+$parent)
- -familyImage "menuIconView.xpm"
- cameraMenu;
- radioMenuItemCollection glCameraCluster;
- menuItem -l "Camera 1" -rb false glCameraItem0;
- menuItem -l "Camera 2" -rb false glCameraItem1;
- menuItem -l "Camera 3" -rb false glCameraItem2;
- menuItem -l "Camera 4" -rb false glCameraItem3;
- setParent -menu ..;
-
- // menu -p $parent
- // -label "Options"
- // -familyImage "menuIconOptions.xpm"
- // optionMenu;
- // menuItem -l "Display Grid Plane" -checkBox off -c "glRender -e -grid #1" gridPlaneItem;
- // menuItem -l "Display Camera Icons" -checkBox off -c "glRender -e -cameraIcons #1" camerIconItem;
- // menuItem -l "Display Light Icons" -checkBox off -c "glRender -e -lightIcons #1" lightIconItem;
- // menuItem -l "Display Emitter Icons" -checkBox off -c "glRender -e -emitterIcons #1" emitterIconItem;
- // menuItem -l "Display Field Icons" -checkBox off -c "glRender -e -fieldIcons #1" fieldIconItem;
- // menuItem -l "Display Collision Icons" -checkBox off -c "glRender -e -collisionIcons #1" collisonIconItem;
- // menuItem -l "Display Transform Icons" -checkBox off -c "glRender -e -transformIcons #1" transformIconItem;
- // menuItem -l "Background Color..." -c ("clearClrRW "+$parent) clearClrItem;
- // setParent -menu ..;
-
- menu -p $parent
- -label "Flipbooks"
- -familyImage "menuIconFlipbooks.xpm"
- flipbookMenu;
-
- // Add menus from previous runs if any
- int $numCurrFlipbooks = size($glHWBufferItemLabels);
- for ($i = 0 ; $i < $numCurrFlipbooks ; $i++)
- {
- menuItem -p flipbookMenu
- -l $glHWBufferItemLabels[$i] -c $glHWBufferItemCallbacks[$i];
- }
- flipbookOptionMenuRW();
-
- setParent -menu ..;
- // Adds support for the Context Sensitive Help Menu.
- //
-
- doHelpMenu($parent,$parent+"|workLyt");
- }
-
- // ========== createWinRW ==========
- //
- // SYNOPSIS
- // Create the window and all the controls.
- //
-
- proc createWinRW( string $win )
- {
- setUITemplate -pst NONE;
-
- // Adds support for the Context Sensitive Help Menu.
- //
- addContextHelpProc $win "buildHardwareRenderBuffContextHelpItems";
-
- // Create window and base container widgets.
- //
- if (`about -mac`)
- {
- window
- -title "Hardware Render Buffer"
- //-menuBar true
- -minimizeButton false
- -maximizeButton false
- -retain
- -sizeable false
- //-resizeToFitChildren true
- -resizeToFitChildren false
- -topLeftCorner 270 560
- $win;
- }
- else {
- window
- -title "Hardware Render Buffer"
- -menuBar true
- -minimizeButton false
- -maximizeButton false
- -retain
- -sizeable false
- -resizeToFitChildren true
- // -resizeToFitChildren false
- -topLeftCorner 270 560
- $win;
- }
-
- string $parent;
- global string $glRenderMenLayout;
-
- if (`about -mac`)
- {
- // Create the layout appropriate for Hardware Render Buffer.
- //
- formLayout renderBufferForm;
- // Create the menubar.
- //
- setParent ($win + "|renderBufferForm");
- $glRenderMenLayout = `menuBarLayout glRenderMenLayout`;
- createMenuRW( $glRenderMenLayout );
- $parent = $glRenderMenLayout;
- }
- else {
- // Create the menubar.
- //
- setParent $win;
- createMenuRW( $win );
- $parent = $win;
- }
-
- formLayout -nd 100 workLyt;
- // Create the timeline.
- //
- setParent ($parent+"|workLyt");
- formLayout timeLineLyt;
- formLayout -e
- -af timeLineLyt left 0
- -af timeLineLyt right 0
- -af timeLineLyt bottom 0
- ($parent+"|workLyt");
-
- frameLayout -lv false timeFrameLyt;
- formLayout -e
- -af timeFrameLyt left 4
- -af timeFrameLyt right 4
- -af timeFrameLyt bottom 4
- timeLineLyt;
-
- formLayout timelineLyt;
- rowLayout
- -numberOfColumns 7
- -columnWidth 1 30
- -columnWidth 2 30
- -columnWidth 3 30
- -columnWidth 4 30
- -columnWidth 5 30
- -columnWidth 6 30
- -columnWidth 7 30
- playbackRow;
- formLayout -e
- -ap playbackRow left -90 50
- -af playbackRow bottom 4
- timelineLyt;
-
- symbolButton
- -image "timerew.xpm"
- -annotation "Go to start of playback range"
- startFrameBtn;
-
- symbolButton
- -image "timeend.xpm"
- -annotation "Step back one frame"
- stepBwdBtn;
-
- symbolButton
- -image "timerev.xpm"
- -annotation "Play backwards"
- playBwdBtn;
-
- symbolButton
- -image "rvRender.xpm"
- -annotation "Test render: Start test render"
- testRenderBtn;
-
- symbolButton
- -image "timeplay.xpm"
- -annotation "Play forward"
- playFwdBtn;
-
- symbolButton
- -image "timestart.xpm"
- -annotation "Step forward one frame"
- stepFwdBtn;
-
- symbolButton
- -image "timefwd.xpm"
- -annotation "Go to end of playback range"
- endFrameBtn;
- setParent ..;
-
- floatField
- -w 65
- -pre 0
- -annotation "Playback Start Time: Set the start time of the playback range"
- timeMinFld;
- formLayout -e
- -af timeMinFld bottom 0
- -af timeMinFld left 2
- timelineLyt;
-
- floatField
- -w 65
- -pre 0
- -annotation "Playback End Time: Set the end time of the playback range"
- timeMaxFld;
- formLayout -e
- -af timeMaxFld bottom 0
- -af timeMaxFld right 2
- timelineLyt;
-
- frameLayout -lv false -bv true -cl false -cll false timeFrameLyt;
- formLayout -e
- -af timeFrameLyt left -2
- -af timeFrameLyt top -2
- -af timeFrameLyt right -2
- -ac timeFrameLyt bottom 6 playbackRow
- timelineLyt;
-
- timePort
- -h 26
- //-annotation "Select the frame for the test render"
- timeSld;
- setParent ..;
- setParent ..;
- setParent ..;
- setParent ..;
-
-
- // Create the OpenGL render buffer.
- //
- setParent ($parent+"|workLyt");
- formLayout viewLyt;
- frameLayout
- -borderVisible true
- -borderStyle "in"
- -collapse false
- -collapsable false
- -labelVisible false
- -width 646
- -height 485
- viewFrame;
-
- glRenderEditor hardwareRenderView;
-
- setParent ..;
- setParent ..;
-
-
- // Attach the shelf, timeline, and viewframe to
- // parent form and to each other as needed.
- //
- setParent ($parent+"|workLyt");
- formLayout -e
- -af timeLineLyt left 0
- -af timeLineLyt right 0
- -af timeLineLyt bottom 0
-
- -af viewLyt left 0
- -af viewLyt top 0
- -af viewLyt right 0
- -ac viewLyt bottom 0 timeLineLyt
- ($parent+"|workLyt");
-
- if(`about -mac`)
- {
- formLayout -edit
- -af $glRenderMenLayout "top" 0
- -af $glRenderMenLayout "left" 0
- -af $glRenderMenLayout "bottom" 0
- -af $glRenderMenLayout "right" 0
- ($win+"|renderBufferForm");
- }
- setUITemplate -ppt;
-
- // Implicitely setting the width again to force a window resize/refresh for Mac.
- //Otherwise, the time slider is not getting displayed for the first time on Jaguar
- if(`about -mac`){
- int $width = `window -q -width $win`;
- window -e -width $width $win;
- }
-
- } // createWinRW //
-
-
-
- // ========== registerRW ==========
- //
- // Description:
- // Register the callbacks on the widgets.
- //
-
- proc registerRW( string $win )
- {
- if(`about -mac`)
- {
- setParent ($win + "|renderBufferForm" + "|glRenderMenLayout");
- }
- else {
- setParent $win;
- }
-
- // Toolbar
- //
- symbolButton -e -c "doGlRender" testRenderBtn;
-
- // Timeline
- //
- if (`isTrue "AnimationExists"` && `exists initTimeSlider`)
- {
- symbolButton -e -c ("playbackRW "+$win+" 1") startFrameBtn;
- symbolButton -e -c ("playbackRW "+$win+" 2") stepBwdBtn;
- symbolButton -e -c ("playbackRW "+$win+" 3") playBwdBtn;
- symbolButton -e -c ("playbackRW "+$win+" 4") playFwdBtn;
- symbolButton -e -c ("playbackRW "+$win+" 5") stepFwdBtn;
- symbolButton -e -c ("playbackRW "+$win+" 6") endFrameBtn;
-
- scriptJob -protected -parent $win -conditionChange playingBack ("playbackScriptJobRW "+$win);
- }
- else
- {
- symbolButton -e -enable false startFrameBtn;
- symbolButton -e -enable false stepBwdBtn;
- symbolButton -e -enable false playBwdBtn;
- symbolButton -e -enable false playFwdBtn;
- symbolButton -e -enable false stepFwdBtn;
- symbolButton -e -enable false endFrameBtn;
- }
-
- floatField -e -cc "playbackOptions -min #1; glRender -e -frameStart #1" timeMinFld;
- floatField -e -cc "playbackOptions -max #1; glRender -e -frameEnd #1" timeMaxFld;
-
-
- // Register with glRender to call flipbookRW when a render
- // sequence is finished, so a menu item will be created and
- // relevant data can be saved to allow the user to see the
- // rendered sequence with fcheck.
- //
- glRender -e -fc "flipbookRW";
-
- // Register a scriptJob for the resolution attribute changes.
- //
- string $hwNodesAry[] = `ls -type hwRenderGlobals`;
- int $hwNodesCnt = size( $hwNodesAry );
-
- if ($hwNodesCnt)
- {
- scriptJob -protected -parent $win -attributeChange ($hwNodesAry[0]+".resolution") ("resChangedScriptJobRW "+$win);
- }
- } // registerRW //
-
-
- // ========== updateWinRW ==========
- //
- // Description:
- // Update the ui controls to match the current render
- // state. For example, set the timeline slider to the
- // current frame range.
- //
-
- global proc updateWinRW( string $win )
- {
-
- if(`about -mac`)
- {
- setParent ($win + "|renderBufferForm" + "|glRenderMenLayout");
- }
- else {
- setParent $win;
- }
-
- // Set frame min/max to current frame range.
- //
- int $fs = `playbackOptions -q -min`;
- int $fe = `playbackOptions -q -max`;
-
- glRender -e -frameStart $fs;
- glRender -e -frameEnd $fe;
-
- floatField -e -v $fs timeMinFld;
- floatField -e -v $fe timeMaxFld;
- }
-
-
- // ========== glRenderWin ==========
- //
- // SYNOPSIS
- // Main entry point. Must be last procedure in file.
- //
-
- global proc int glRenderWin()
- {
- global string $glRenderBufferWin;
-
- string $win = "glRenderWindow";
- if (`about -mac`)
- {
- $glRenderBufferWin = $win + "|renderBufferForm" + "|glRenderMenLayout";
- }
- else {
- $glRenderBufferWin = $win;
- }
-
- int $firstTime = 0;
-
- if (!`licenseCheck -m "edit" -typ "complete"`) {
- warning "You are not licensed to use the Hardware Render Window.";
- return 1;
- }
-
- if (! `window -exists $win`)
- {
- createWinRW( $win );
- registerRW( $win );
- }
-
- updateWinRW( $win );
- showWindow( $win );
-
- // For now, resize the window whenever it is posted because the
- // scriptJob fails on File->New. This call can be removed when
- // that bug is fixed (79322).
- //
- resChangedScriptJobRW( $win );
-
- if ( `about -mac` ) {
- // The timeline does not return it's true size the first time on the
- // Mac, so we need to give a second kick.
- //
- resChangedScriptJobRW( $win );
- }
-
- return( 1 );
-
- } // glRenderWin //
-